﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Indie_Game_Contest
{
    class GameOverState : IGameState
    {
        //////////////////////////////////////////////////////////////////////////
        // Data Members
        static GameOverState instance = new GameOverState();
        TextureManager tm = TextureManager.Instance;

        int bgID;
        int fontID;
        private float m_fPrevVol = MediaPlayer.Volume;

        //////////////////////////////////////////////////////////////////////////
        // Methods
        GameOverState()
        {

        }
        public override void Update(float dt)
        {
            MediaPlayer.Volume -= (dt/2.0f);
        }
        public override bool Input()
        {
            CInput input = CInput.Instance;
            if (input.KeyPressed(Keys.Escape) || input.KeyPressed(Keys.Enter) ||
                input.GamePadButtonPressed(Buttons.Start) || input.GamePadButtonPressed(Buttons.A))
            {
                Game1.Instance.RemoveState();
                Game1.Instance.AddState(MainMenuSate.Instance);
                Game1.Instance.RemoveState(GameplayState.Instance);
            }

            return true;
        }
        public override void Render()
        {
            WorldData.spriteBatch.Draw(tm.GetTexture(bgID),
                new Rectangle(0, 0, WorldData.WindowWidth, WorldData.WindowHeight), Color.FromNonPremultiplied(255, 255, 255, 187));

            WorldData.spriteBatch.DrawString(tm.GetSpriteFont(fontID), "SHOW'S OVER",
                new Vector2(WorldData.WindowWidth / 2 - 12 * 9, WorldData.WindowHeight / 2 - 48), Color.SkyBlue);
        }
        public override void Enter()
        {
            m_fPrevVol = MediaPlayer.Volume;
            //AudioManager.Instance.StopSong("Bob's Adventures - back34_0");
            AudioManager.Instance.PlaySFX("applause");
        }
        public override void Exit()
        {
            MediaPlayer.Volume = m_fPrevVol;
        }

        //////////////////////////////////////////////////////////////////////////
        // Properties
        public int FontID
        {
            get { return fontID; }
            set { fontID = value; }
        }
        public int BgID
        {
            get { return bgID; }
            set { bgID = value; }
        }
        public static Indie_Game_Contest.GameOverState Instance
        {
            get { return instance; }
        }
    }
}
